package item.service.Impl;


import commons.pojo.Ans;
import commons.pojo.Item;
import commons.pojo.Shipin;
import commons.vo.LivegoodsResult;
import item.dao.ItemDao;
import item.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.regex.Pattern;

@Service
public class ItemServiceImpl implements ItemService {
    @Autowired
    private ItemDao itemDao;

    @Autowired
    private MongoTemplate mongoTemplate;
    @Override
    public LivegoodsResult getItem(int page,int rows,String tag) {
        return itemDao.selectRecommendation(page, rows, tag);

    }

    @Override
    public Item likeItem(int sid) {
        Query query = new Query();
        query.addCriteria(Criteria.where("id").is(sid));

        Item items = mongoTemplate.findOne(query, Item.class);
        return items;
    }

    @Override
    public Shipin likeShiPin(int sid) {
        Query query = new Query();
        query.addCriteria(Criteria.where("id").is(sid));
        Shipin one = mongoTemplate.findOne(query, Shipin.class);
        return one;
    }

    @Override
    public LivegoodsResult selectShiPinPage(int page) {
        return itemDao.seclectShiPin(page);
    }

    @Override
    public LivegoodsResult selectFaShiPage(int page) {
        return itemDao.selectFaShiPage(page);
    }

    @Override
    public LivegoodsResult selectFaShi(int id) {
        return itemDao.selectFaShi(id);
    }

    @Override
    public LivegoodsResult selectHuaTi() {
        return itemDao.selectHuaTi();
    }

    @Override
    public LivegoodsResult selectHuaTiId(int id) {
        return itemDao.selectHuaTiId(id);
    }

    @Override
    public LivegoodsResult selectJingXing() {
        return itemDao.selectJingXing();
    }

    @Override
    public LivegoodsResult selectJingXingId(int id) {
        return itemDao.selectJingXingId(id);
    }
}
